package com.example.ustoreui;

import java.io.Serializable;
import java.util.Random;

import com.vaadin.data.util.BeanItemContainer;

@SuppressWarnings("serial")
public class FileContainer extends BeanItemContainer<UFile> implements
		Serializable {

	/**
	 * Natural property order for Person bean. Used in tables and forms.
	 */
	public static final Object[] NATURAL_COL_ORDER = new Object[] { "marcacao",
			"nome", "tamanho", "atualizacao" };

	/**
	 * "Human readable" captions for properties in same order as in
	 * NATURAL_COL_ORDER.
	 */
	public static final String[] COL_HEADERS = new String[] { " ",
			"Nome do Item", "Tamanho", "Atualizado em" };

	public FileContainer() {
		super(UFile.class);
	}

	public static FileContainer createWithTestData() {
		final boolean[] marcacoes = { true, false, true, false, true, false,
				true, false, true, false, true, false, true, false };
		final String[] names = { "Peter", "Alice", "Joshua", "Mike", "Olivia",
				"Nina", "Alex", "Rita", "Dan", "Umberto", "Henrik", "Rene",
				"Lisa", "Marge" };
		final String[] tamanhos = { "56kb", "1Mb", "20Mb", "56kb", "1Mb",
				"20Mb", "56kb", "1Mb", "20Mb", "56kb", "1Mb", "20Mb", "56kb",
				"1Mb" };
		final String[] atualizacoes = { "05/12/2011", "05/12/2011",
				"05/12/2011", "05/12/2011", "05/12/2011", "05/12/2011",
				"05/12/2011", "05/12/2011", "05/12/2011", "05/12/2011",
				"05/12/2011", "05/12/2011", "05/12/2011", "05/12/2011" };
		FileContainer c = null;
		Random r = new Random(0);
		c = new FileContainer();
		for (int i = 0; i < 100; i++) {
			UFile p = new UFile();
			p.setMarcacao(marcacoes[r.nextInt(marcacoes.length)]);
			p.setNome(names[r.nextInt(names.length)]);
			p.setTamanho(tamanhos[r.nextInt(tamanhos.length)]);
			p.setAtualizacao(atualizacoes[r.nextInt(atualizacoes.length)]);
			c.addItem(p);
		}

		return c;
	}
}
